# -*- coding: utf-8 -*-
# @version : 1.0
# @File    : __init__.py.py
# @Date    : 2024/12/26 11:42
# @Author  : GlenZhao
# @Desc    :
from pydantic import BaseModel, ConfigDict, field_serializer
from typing import Any
from core.data_types import DatetimeStr


class Menu(BaseModel):
    model_config = ConfigDict(from_attributes=True)

    id: int
    name: str
    title: str
    icon: str | None = None
    component: str | None = None
    redirect: str | None = None
    path: str | None = None
    disabled: bool = False
    hidden: bool = False
    order: int | None = None
    perms: str | None = None
    parent_id: int | None = None
    menu_type: str

class MenuSimpleOut(Menu):
    model_config = ConfigDict(from_attributes=True)

    id: int
    create_datetime: DatetimeStr
    update_datetime: DatetimeStr


class Meta(BaseModel):
    model_config = ConfigDict(from_attributes=True)
    title: str
    icon: str | None = None
    hidden: bool = False
    disabled: bool = False
    perms: str | None = None


class SubMenuOut(BaseModel):
    model_config = ConfigDict(from_attributes=True)
    name: str
    path: str
    component: str
    meta: Any


# 路由展示
class RouterOut(BaseModel):
    model_config = ConfigDict(from_attributes=True)

    name: str
    rank: int
    title: str | None = None
    component: str | None = None
    path: str
    redirect: str | None = None
    meta: Meta | None = None
    order: int | None = None
    children: list[dict] = []
